const {
  post
} = require("../../untils/db");

Page({
  data: {
    show: false,
    release1: {},
    time: "",
    addScore: "",
    taskType: "",
    downScore: "",
    isVerify: "",
    perple: ""
  },
  renyuan() {
    this.setData({
      show: true
    })
  },
  onClose() {
    this.setData({
      show: false
    });
  },
  async onLoad(e) {
    console.log(e);
    let token = wx.getStorageSync('login')
    let release1 = ""
    if (wx.getStorageSync('release1') == "") {
      release1 = {
        name: "无",
        content: "无"
      }
    } else {
      release1 = wx.getStorageSync('release1')
    }
    // let release2 = wx.getStorageSync('release2')

    let release2 = ""
    if (wx.getStorageSync('release2') == "") {
      this.setData({
        perple: ["无"]
      })
    } else {
      let arr = wx.getStorageSync('release2')
      console.log(arr);
      let res = await post("/api/users/info", {
        ids: arr.join(",")
      }, token)
      console.log(res.data.data);
      this.setData({
        perple: res.data.data
      })
    }

    let week = wx.getStorageSync('week')
    let date = wx.getStorageSync('Date')



    var time = ""
    console.log(date);
    if (date == "") {
      time = "暂无数据"
    } else {
      let begin = new Date(date.validStartTime)
      let over = new Date(date.validEndTime)
      console.log(begin, over);
      time = `${begin.getFullYear()}-${begin.getMonth()+1}-${begin.getDate()}---${over.getFullYear()}-${over.getMonth()+1}-${over.getDate()}`

    }
    console.log(time);
    this.setData({
      release1,
      time,
      addScore: e.addScore,
      taskType: e.taskType == "" ? '3' : (e.taskType == 1 ? '1' : '0'),
      downScore: e.downScore,
      isVerify: e.isVerify == "" ? '3' : (e.isVerify == 1 ? '1' : '0'),
    }, () => {
      console.log(this.data.taskType == "" ? '3' : (this.data.taskType == 1 ? '1' : '0'))
      if (this.data.taskType == 0) {

      }
    })
  },
  truer(){
    wx.navigateBack()
  }
});